package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.RoomPerConsumption;
import com.eling.elcms.travel.model.view.ConsumpSaveView;
import com.eling.elcms.travel.service.IRoomPerConsumptionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class RoomPerConsumptionController extends BaseFormController{

	@Autowired
	private IRoomPerConsumptionManager perConsumptionManager;
	
	@RequestMapping("/api/roomperconsumption/save")
    @ResponseBody
	public RoomPerConsumption save(@ModelAttribute@ModelFilling RoomPerConsumption cond){
		return perConsumptionManager.save(cond);
	}
	
	@RequestMapping("/api/roomperconsumption/{pkRoomPerConsumption}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkRoomPerConsumption){
		perConsumptionManager.remove(pkRoomPerConsumption);
		return new Msg("删除成功");
	}
	
	@RequestMapping("/api/roomperconsumption/query")
    @ResponseBody
	public List<RoomPerConsumption> query(@ModelAttribute RoomPerConsumption cond){
		return perConsumptionManager.query(cond);
	}
	
	@RequestMapping("/api/roomperconsumption/search*")
	@ResponseBody
	public List<RoomPerConsumption> search(@ModelAttribute SearchCondition sc,@ModelAttribute RoomPerConsumption cond){
		sc.setQueryCondition(cond);
		return perConsumptionManager.search(sc);
	}
	
	@RequestMapping("/api/roomperconsumption/saveconsump")
    @ResponseBody
	public RoomPerConsumption saveConsump(@ModelAttribute ConsumpSaveView view){
		return perConsumptionManager.saveConsump(view);
	}
	
}
